/* 
 *	Copyright 2014  Yanqing Wu
 *		email: yqwu_yqwu@126.com
 *
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
*/

#pragma once

#include "StdCtrlSkin_Enums.h"
#include "StdCtrlSkin_BaseElt.h"
#include "StdCtrlSkinAttrib.h"

class CStdCtrlSkinRow;

/*
 *	A cell in the table to manage controls
 */
class CStdCtrlSkinCell : public CStdCtrlSkin_BaseElt
{
public:

	//	Start column
	UINT col;
	//	Attributes
	CStdCtrlSkinAttrib attrib;
	//	Row span and columnspan of the control in this cell, default 1
	UINT rowspan, colspan;
	//	String id of control in this cell
	CString ctrl_id;
protected:
	//	Rect struct for the control in it
	CRect m_ctrl_rect;
	//	Back pointer to row
	CStdCtrlSkinRow* m_pRow;


public:
	CStdCtrlSkinCell(CStdCtrlSkinRow* pRow=nullptr);
	CStdCtrlSkinCell(CComPtr<IXMLDOMNode>, CStdCtrlSkinRow* pRow);
	virtual void InitDataElt(CStdCtrlSkinRow* pRow);
	virtual ~CStdCtrlSkinCell(void);

	CString GetFilePath(void);

	virtual CStdCtrlSkinAttrib GetAttribFinal(void);

	virtual UINT GetMinWidth(void);
	virtual UINT GetMinHeight(void);

	virtual std::map<CString, CString> GetCustomAttrib(void)
	{
		return m_custom_attrib;
	}

	virtual CRect GetCellRect(void);
	virtual CRect GetCtrlRect(void);

#ifdef __DUMPTEST
	virtual void Dump(std::ofstream& fio, CStdCtrlSkin_EnumDump type) override;
#endif

protected:
	virtual bool LoadXmlNode(CComPtr<IXMLDOMNode> spNode);
	virtual void DumpCellRect(std::ofstream& fio, CStdCtrlSkin_EnumDump type);
	virtual void DumpCtrlRect(std::ofstream& fio, CStdCtrlSkin_EnumDump type);
	virtual void DumpCellAttribInst(std::ofstream& fio, CStdCtrlSkin_EnumDump type);
	virtual void DumpCellAttribFinal(std::ofstream& fio, CStdCtrlSkin_EnumDump type);
};

